package com.allen.bill;

import java.io.File;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class FetchContext {
    private static final FetchContext instance = new FetchContext();
    private String                    configDir;
    private static ApplicationContext context;

    private FetchContext() {
    }

    public static FetchContext getInstance() {
        return instance;
    }

    public ApplicationContext getContext() {
        if (context == null) {
            String[] xmlFiles = new String[] { configDir + File.separator
                                               + "applicationContext.xml" };
            context = new FileSystemXmlApplicationContext(xmlFiles);
            //context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");

        }
        return context;

    }

    public Object getBeans(String bean) {
        return context.getBean(bean);
    }

    public String getConfigDir() {
        return configDir;
    }

    public void setConfigDir(String configDir) {
        this.configDir = configDir;
    }
    
    
}
